package com.example.administrator.caigou51.widget.dialog;


import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ab.util.AbViewUtil;
import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.global.App;

import de.greenrobot.event.EventBus;


/**
 * Create custom Dialog windows for your application Custom dialogs rely on
 * custom layouts wich allow you to create and use your own look & feel.
 * <p/>
 * Under GPL v3 : http://www.gnu.org/licenses/gpl-3.0.html
 *
 * @author antoine vianey
 */
public class ShareDialog2 extends Dialog implements View.OnClickListener {
    private TextView textView_title;
    private LinearLayout linearLayout_penyouquan;
    private LinearLayout linearLayout_weixin;
    private LinearLayout linearLayout_qq;
    private LinearLayout linearLayout_qqzone;
    private TextView textView_cancle;
    private ShareOnClick shareOnClick;
    private Context context;
    public ShareDialog2(Context context, ShareOnClick shareOnClick) {
        super(context, R.style.dialogselect);
        this.shareOnClick = shareOnClick;
        this.context=context;
        setCustomDialog();
    }

    public ShareDialog2(Context context, int theme, ShareOnClick shareOnClick) {
        super(context, theme);
        this.context=context;
        this.shareOnClick = shareOnClick;
    }

    private void setCustomDialog() {
        View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_share2, null);
        AbViewUtil.scaleContentView((ViewGroup) mView);
        textView_title = (TextView) mView.findViewById(R.id.textView_title);
        textView_title.getLayoutParams().width= App.getInstance().screenWidth;
        linearLayout_penyouquan = (LinearLayout) mView.findViewById(R.id.linearLayout_penyouquan);
        linearLayout_weixin = (LinearLayout) mView.findViewById(R.id.linearLayout_weixin);
        linearLayout_qq = (LinearLayout) mView.findViewById(R.id.linearLayout_qq);
        linearLayout_qqzone = (LinearLayout) mView.findViewById(R.id.linearLayout_qqzone);
        textView_cancle = (TextView) mView.findViewById(R.id.textView_cancle);

        linearLayout_penyouquan.setOnClickListener(this);
        linearLayout_weixin.setOnClickListener(this);
        linearLayout_qq.setOnClickListener(this);
        linearLayout_qqzone.setOnClickListener(this);

        textView_cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ShareDialog2.this.dismiss();
            }
        });
        super.setContentView(mView);
    }
    public void setTitle(CharSequence title) {
        textView_title.setText(title);
    }
    @Override
    public void onClick(View v) {

        shareOnClick.toShare(v);
    }

    public interface ShareOnClick {
        public void toShare(View viewl);
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }
}